package cn.historia.domain.strategy.service.rule.tree.factory;

import cn.historia.domain.strategy.model.valobj.RuleLogicCheckTypeVO;
import cn.historia.domain.strategy.model.valobj.RuleTreeVO;
import cn.historia.domain.strategy.service.rule.tree.ILogicTreeNode;
import cn.historia.domain.strategy.service.rule.tree.factory.engine.IDecisionTreeEngine;
import cn.historia.domain.strategy.service.rule.tree.factory.engine.impl.DecisionTreeEngine;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @package: cn.historia.domain.strategy.service.rule.tree.factory
 * @className: DefaultTreeFactory
 * @author: 云溪
 * @description: 规则树工厂
 * @date: 2025/7/24 16:04
 * @version: 1.0
 */
@Service
public class DefaultTreeFactory {

    private final Map<String, ILogicTreeNode> logicTreeNodeGroup;

    //构造注入
    private DefaultTreeFactory(Map<String, ILogicTreeNode> logicTreeNodeGroup){
        this.logicTreeNodeGroup = logicTreeNodeGroup;
    }

    public IDecisionTreeEngine openLogicTree(RuleTreeVO ruleTreeVO) {
        return new DecisionTreeEngine(logicTreeNodeGroup, ruleTreeVO);
    }


    /**
     * 决策树各动作实体
     */
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class TreeActionEntity {
        private RuleLogicCheckTypeVO ruleLogicCheckType;
        private StrategyAwardVO strategyAwardVO;
    }


    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class StrategyAwardVO{
        /** 抽奖奖品ID - 内部流转使用 */
        private Integer awardId;
        /** 抽奖奖品规则 */
        private String awardRuleValue;

    }

}
